import React from 'react';
import {Navigate} from 'react-router-dom';

export default function Home() {
	const [num, setNum] = React.useState(0);

  /* 
      Navigate组件有两个参数
        1,to:跳转的路由地址
        2,replace:是否为replace跳转转入boolean值,默认为false,push跳转
  */
	return (
		<div>
			<h1>我是Home的内容</h1>
			{num === 2 ? <Navigate to={'/about'} replace={true}></Navigate> : <h4>当前总数:{num}</h4>}
			<button
				onClick={() => {
					setNum(num + 1);
				}}>
				+1
			</button>
		</div>
	);
}
